/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package semant.first_pass;

import errors.ErrorEchoer;
import semant.Env;
import syntaxtree.Program;
import syntaxtree.VisitorAdapter;


/**
 *
 * @author Thiago
 */
class ProgramHandler extends VisitorAdapter {

    private Env result;

    private ProgramHandler(ErrorEchoer err)
    {
        super();

        result = new Env(err);
    }

    static Env firstPass(ErrorEchoer err, Program p)
    {
        ProgramHandler h = new ProgramHandler(err);

        p.accept(h);

        return h.result;
    }

    public void visit(Program node)
    {
        //classe principal
        MainClassHandler.firstPass(result,node.mainClass);

        //outras classes
        ClassDeclListHandler.firstPass(result, node.classList);
    }

}
